<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="renderer" content="webkit">
    <title></title>
    <link rel="stylesheet" th:href="@{/css/pintuer.css}">
    <link rel="stylesheet" th:href="@{/css/admin.css}">
    <script th:src="@{/js/jquery.js}"></script>
    <script th:src="@{/js/pintuer.js}"></script>
    <style>
        .state-0 {
            color: red;
        }

        .state-1 {
            color: black;
        }

        .state-2 {
            color: blue;
        }
    </style>

</head>

<body>
<form method="post" action="" id="listform">
    <div class="panel admin-panel">
        <div class="panel-head"><strong class="icon-reorder"> 内容列表</strong> <a href=""
                                                                               style="float:right; display:none;">添加字段</a></div>
        <div class="padding border-bottom">
            <ul class="search" style="padding-left:10px;">
                <li><a class="button border-main icon-plus-square-o" href="add.html"> 添加内容</a></li>
                <li>搜索：</li>
                <li>首页
                    <select name="s_ishome" class="input" onchange="changesearch()"
                            style="width:60px; line-height:17px; display:inline-block">
                        <option value="">选择</option>
                        <option value="1">是</option>
                        <option value="0">否</option>
                    </select>
                    &nbsp;&nbsp;
                    推荐
                    <select name="s_isvouch" class="input" onchange="changesearch()"
                            style="width:60px; line-height:17px;display:inline-block">
                        <option value="">选择</option>
                        <option value="1">是</option>
                        <option value="0">否</option>
                    </select>
                    &nbsp;&nbsp;
                    置顶
                    <select name="s_istop" class="input" onchange="changesearch()"
                            style="width:60px; line-height:17px;display:inline-block">
                        <option value="">选择</option>
                        <option value="1">是</option>
                        <option value="0">否</option>
                    </select>
                </li>
                <if condition="$iscid eq 1">
                    <li>
                        <select name="cid" class="input" style="width:200px; line-height:17px;"
                                onchange="changesearch()">
                            <option value="">请选择分类</option>
                            <option value="">产品分类</option>
                            <option value="">产品分类</option>
                            <option value="">产品分类</option>
                            <option value="">产品分类</option>
                        </select>
                    </li>
                </if>
                <li>
                    <input type="text" placeholder="请输入搜索关键字" name="keywords" class="input"
                           style="width:250px; line-height:17px;display:inline-block"/>
                    <a href="javascript:void(0)" class="button border-main icon-search" onclick="changesearch()">
                        搜索</a>
                </li>
            </ul>
        </div>

        <table class="table table-hover text-center">
            <tr>
                <th style="text-align:left; padding-left:20px;">
                    <input type="checkbox" id="cbTrigger"/>
                </th>
                <th>排序</th>
                <th>头像</th>
                <th>昵称</th>
                <th>性别</th>
                <th>生日</th>
                <th>邮箱</th>
                <th>电话</th>
                <th>账户</th>
                <th>积分</th>
                <th>等级</th>
                <th>状态</th>
                <th>创建时间</th>
                <th>操作</th>
            </tr>
            <volist name="list" id="vo">
                <tr th:each="user:${pageBean.records}">
                    <td style="text-align:left; padding-left:20px;">
                        <input type="checkbox" name="idCB" value="1">
                    </td>
                    <td th:text="${user.id}"></td>
                    <td>
                        <img th:src="@{/{p}(p=${user.avatar})}" alt="" style="width: 120px;"/>
                    </td>
                    <td th:text="${user.nickname}"></td>
                    <td th:text="${user.gender?'男':'女'}"></td>
                    <td th:text="${user.birth}"></td>
                    <td th:text="${user.email}"></td>
                    <td th:text="${user.phone}"></td>
                    <td th:text="${user.account}"></td>
                    <td th:text="${user.credit}"></td>
                    <td th:text="${user.level}"></td>
                    <td>
                        <span th:text="${@stateConstant.getUserStateName(user.state)}" th:class="${'state-' + user.state}"></span>
                    </td>
                    <td th:text="${user.createTime}"></td>
                    <td>
                        <div class="button-group"><a class="button border-main" href="add.html"><span
                                class="icon-edit"></span> 修改</a> <a class="button border-red"
                                                                    href="javascript:void(0)" onclick="return del(1,1,1)"><span
                                class="icon-trash-o"></span> 删除</a></div>
                    </td>
                </tr>
                <tr>
                    <td colspan="14">
                        <div class="pagelist">
                            <a th:href="@{/user/openPage?pageNum=1}">首页</a>
                            <a th:if="${pageBean.pageNum}>1" th:href="@{/user/openPage?pageNum={pageNum}(pageNum=${pageBean.pageNum}-1)}">上一页</a>
                            <a th:classappend="${index == pageBean.pageNum?'current':'_'}" th:each="index:${#numbers.sequence(1,pageBean.pages)}" th:href="@{/user/openPage?pageNum={pageNum}(pageNum=${index})}">[[${index}]]</a>
                            <a th:if="${pageBean.pageNum<pageBean.pages}" th:href="@{/user/openPage?pageNum={pageNum}(pageNum=${pageBean.pageNum}+1)}">下一页</a>
                            <a th:href="@{/user/openPage?pageNum={pageNum}(pageNum=${pageBean.pages})}">尾页</a>
                        </div>
                    </td>
                </tr>
        </table>

    </div>
</form>
<script type="text/javascript">
    //搜索
    function changesearch() {

    }

    //单个删除
    function del(id, mid, iscid) {
        if (confirm("您确定要删除吗?")) {

        }
    }

    //复选框全选or取消全选
    $("#cbTrigger").change(function () {
        if ($("#cbTrigger").is(':checked')) {
            $("input[name='idCB']").prop("checked", true);
        } else {
            $("input[name='idCB']").prop('checked', false);
        }
    })

    //批量删除
    function batchDelete() {
        let ids = "";
        $('input:checkbox[name=idCB]:checked').each(function (i) {
            ids += $(this).val() + ",";
        });
        ids = ids.substring(0, ids.length - 1);
        if (ids != "") {
            let t = confirm("您确认要删除选中的内容吗？");
            if (t) {
                alert(ids);
                return true;
            }
        } else {
            alert("请选择您要删除的内容!");
            return false;
        }
    }

    //批量排序
    function sorts() {
        let Checkbox = false;
        $("input[name='id[]']").each(function () {
            if (this.checked == true) {
                Checkbox = true;
            }
        });
        if (Checkbox) {

            $("#listform").submit();
        } else {
            alert("请选择要操作的内容!");
            return false;
        }
    }


    //批量首页显示
    function changeishome(o) {
        let Checkbox = false;
        $("input[name='id[]']").each(function () {
            if (this.checked == true) {
                Checkbox = true;
            }
        });
        if (Checkbox) {

            $("#listform").submit();
        } else {
            alert("请选择要操作的内容!");

            return false;
        }
    }

    //批量推荐
    function changeisvouch(o) {
        let Checkbox = false;
        $("input[name='id[]']").each(function () {
            if (this.checked == true) {
                Checkbox = true;
            }
        });
        if (Checkbox) {


            $("#listform").submit();
        } else {
            alert("请选择要操作的内容!");

            return false;
        }
    }

    //批量置顶
    function changeistop(o) {
        let Checkbox = false;
        $("input[name='id[]']").each(function () {
            if (this.checked == true) {
                Checkbox = true;
            }
        });
        if (Checkbox) {

            $("#listform").submit();
        } else {
            alert("请选择要操作的内容!");

            return false;
        }
    }


    //批量移动
    function changecate(o) {
        let Checkbox = false;
        $("input[name='id[]']").each(function () {
            if (this.checked == true) {
                Checkbox = true;
            }
        });
        if (Checkbox) {

            $("#listform").submit();
        } else {
            alert("请选择要操作的内容!");

            return false;
        }
    }

    //批量复制
    function changecopy(o) {
        let Checkbox = false;
        $("input[name='id[]']").each(function () {
            if (this.checked == true) {
                Checkbox = true;
            }
        });
        if (Checkbox) {
            let i = 0;
            $("input[name='id[]']").each(function () {
                if (this.checked == true) {
                    i++;
                }
            });
            if (i > 1) {
                alert("只能选择一条信息!");
                $(o).find("option:first").prop("selected", "selected");
            } else {

                $("#listform").submit();
            }
        } else {
            alert("请选择要复制的内容!");
            $(o).find("option:first").prop("selected", "selected");
            return false;
        }
    }

</script>
</body>

</html>